blob: b5c7479ac031f1d95f98439bee2d4fa9a2f4a2bc [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Junio C Hamanod9d71c02006-02-08 00:52:336<meta name="generator" content="AsciiDoc 7.0.2" />
Junio C Hamano1a4e8412005-12-27 08:17:237<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
19a { color: blue; }
20a:visited { color: fuchsia; }
21
22em {
23 font-style: italic;
24}
25
26strong {
27 font-weight: bold;
28}
29
30tt {
31 color: navy;
32}
33
34h1, h2, h3, h4, h5, h6 {
35 color: #527bbd;
36 font-family: sans-serif;
37 margin-top: 1.2em;
38 margin-bottom: 0.5em;
39 line-height: 1.3;
40}
41
42h1 {
43 border-bottom: 2px solid silver;
44}
45h2 {
46 border-bottom: 2px solid silver;
47 padding-top: 0.5em;
48}
49
50div.sectionbody {
51 font-family: serif;
52 margin-left: 0;
53}
54
55hr {
56 border: 1px solid silver;
57}
58
59p {
60 margin-top: 0.5em;
61 margin-bottom: 0.5em;
62}
63
64pre {
65 padding: 0;
66 margin: 0;
67}
68
69span#author {
70 color: #527bbd;
71 font-family: sans-serif;
72 font-weight: bold;
73 font-size: 1.2em;
74}
75span#email {
76}
77span#revision {
78 font-family: sans-serif;
79}
80
81div#footer {
82 font-family: sans-serif;
83 font-size: small;
84 border-top: 2px solid silver;
85 padding-top: 0.5em;
86 margin-top: 4.0em;
87}
88div#footer-text {
89 float: left;
90 padding-bottom: 0.5em;
91}
92div#footer-badges {
93 float: right;
94 padding-bottom: 0.5em;
95}
96
97div#preamble,
98div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
99div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
100div.admonitionblock {
101 margin-right: 10%;
102 margin-top: 1.5em;
103 margin-bottom: 1.5em;
104}
105div.admonitionblock {
106 margin-top: 2.5em;
107 margin-bottom: 2.5em;
108}
109
110div.content { /* Block element content. */
111 padding: 0;
112}
113
114/* Block element titles. */
115div.title, caption.title {
116 font-family: sans-serif;
117 font-weight: bold;
118 text-align: left;
119 margin-top: 1.0em;
120 margin-bottom: 0.5em;
121}
122div.title + * {
123 margin-top: 0;
124}
125
126td div.title:first-child {
127 margin-top: 0.0em;
128}
129div.content div.title:first-child {
130 margin-top: 0.0em;
131}
132div.content + div.title {
133 margin-top: 0.0em;
134}
135
136div.sidebarblock > div.content {
137 background: #ffffee;
138 border: 1px solid silver;
139 padding: 0.5em;
140}
141
142div.listingblock > div.content {
143 border: 1px solid silver;
144 background: #f4f4f4;
145 padding: 0.5em;
146}
147
148div.quoteblock > div.content {
149 padding-left: 2.0em;
150}
151div.quoteblock .attribution {
152 text-align: right;
153}
154
155div.admonitionblock .icon {
156 vertical-align: top;
157 font-size: 1.1em;
158 font-weight: bold;
159 text-decoration: underline;
160 color: #527bbd;
161 padding-right: 0.5em;
162}
163div.admonitionblock td.content {
164 padding-left: 0.5em;
165 border-left: 2px solid silver;
166}
167
168div.exampleblock > div.content {
169 border-left: 2px solid silver;
170 padding: 0.5em;
171}
172
173div.verseblock div.content {
174 white-space: pre;
175}
176
177div.imageblock div.content { padding-left: 0; }
178div.imageblock img { border: 1px solid silver; }
179span.image img { border-style: none; }
180
181dl {
182 margin-top: 0.8em;
183 margin-bottom: 0.8em;
184}
185dt {
186 margin-top: 0.5em;
187 margin-bottom: 0;
188 font-style: italic;
189}
190dd > *:first-child {
191 margin-top: 0;
192}
193
194ul, ol {
195 list-style-position: outside;
196}
197ol.olist2 {
198 list-style-type: lower-alpha;
199}
200
201div.tableblock > table {
202 border-color: #527bbd;
203 border-width: 3px;
204}
205thead {
206 font-family: sans-serif;
207 font-weight: bold;
208}
209tfoot {
210 font-weight: bold;
211}
212
213div.hlist {
214 margin-top: 0.8em;
215 margin-bottom: 0.8em;
216}
217td.hlist1 {
218 vertical-align: top;
219 font-style: italic;
220 padding-right: 0.8em;
221}
222td.hlist2 {
223 vertical-align: top;
224}
225
226@media print {
227 div#footer-badges { display: none; }
228}
229include::./stylesheets/xhtml11-manpage.css[]
230/* Workarounds for IE6's broken and incomplete CSS2. */
231
232div.sidebar-content {
233 background: #ffffee;
234 border: 1px solid silver;
235 padding: 0.5em;
236}
237div.sidebar-title, div.image-title {
238 font-family: sans-serif;
239 font-weight: bold;
240 margin-top: 0.0em;
241 margin-bottom: 0.5em;
242}
243
244div.listingblock div.content {
245 border: 1px solid silver;
246 background: #f4f4f4;
247 padding: 0.5em;
248}
249
250div.quoteblock-content {
251 padding-left: 2.0em;
252}
253
254div.exampleblock-content {
255 border-left: 2px solid silver;
256 padding-left: 0.5em;
257}
258</style>
259<title>git-diff-tree(1)</title>
260</head>
261<body>
262<div id="header">
263<h1>
264git-diff-tree(1) Manual Page
265</h1>
266<h2>NAME</h2>
267<div class="sectionbody">
268<p>git-diff-tree -
269 Compares the content and mode of blobs found via two tree objects
270</p>
271</div>
272</div>
273<h2>SYNOPSIS</h2>
274<div class="sectionbody">
Junio C Hamano235a91e2006-01-07 01:13:58275<div class="verseblock">
Junio C Hamanofb56a962006-01-28 10:38:19276<div class="content"><em>git-diff-tree</em> [--stdin] [-m] [-s] [-v] [--no-commit-id] [--pretty]
277 [-t] [-r] [-c | --cc] [--root] [&lt;common diff options&gt;]
278 &lt;tree-ish&gt; [&lt;tree-ish&gt;] [&lt;path&gt;&#8230;]</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23279</div>
280<h2>DESCRIPTION</h2>
281<div class="sectionbody">
282<p>Compares the content and mode of the blobs found via two tree objects.</p>
283<p>If there is only one &lt;tree-ish&gt; given, the commit is compared with its parents
284(see --stdin below).</p>
285<p>Note that "git-diff-tree" can use the tree encapsulated in a commit object.</p>
286</div>
287<h2>OPTIONS</h2>
288<div class="sectionbody">
289<dl>
290<dt>
291-p
292</dt>
293<dd>
294<p>
295 Generate patch (see section on generating patches)
296</p>
297</dd>
298<dt>
299-u
300</dt>
301<dd>
302<p>
303 Synonym for "-p".
304</p>
305</dd>
306<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34307--raw
308</dt>
309<dd>
310<p>
311 Generate the raw format.
312</p>
313</dd>
314<dt>
Junio C Hamano54559c82006-04-13 07:45:12315--patch-with-raw
316</dt>
317<dd>
318<p>
Junio C Hamano9ae1a062006-07-10 08:12:34319 Synonym for "-p --raw".
Junio C Hamano54559c82006-04-13 07:45:12320</p>
321</dd>
322<dt>
Junio C Hamano4a9a76a2006-10-01 05:40:29323--stat[=width[,name-width]]
Junio C Hamanoba7c8d82006-04-15 06:17:42324</dt>
325<dd>
326<p>
Junio C Hamano4a9a76a2006-10-01 05:40:29327 Generate a diffstat. You can override the default
328 output width for 80-column terminal by "--stat=width".
329 The width of the filename part can be controlled by
330 giving another width to it separated by a comma.
Junio C Hamanoba7c8d82006-04-15 06:17:42331</p>
332</dd>
333<dt>
Junio C Hamanofbe00522006-10-19 05:58:48334--numstat
335</dt>
336<dd>
337<p>
338 Similar to --stat, but shows number of added and
339 deleted lines in decimal notation and pathname without
Junio C Hamanod793de52006-12-26 09:11:43340 abbreviation, to make it more machine friendly. For
341 binary files, outputs two <tt>-</tt> instead of saying
342 <tt>0 0</tt>.
Junio C Hamanofbe00522006-10-19 05:58:48343</p>
344</dd>
345<dt>
Junio C Hamano7d23f5e2006-12-16 07:44:04346--shortstat
347</dt>
348<dd>
349<p>
350 Output only the last line of the --stat format containing total
351 number of modified files, as well as number of added and deleted
352 lines.
353</p>
354</dd>
355<dt>
Junio C Hamano6959c6c2006-05-17 10:34:11356--summary
357</dt>
358<dd>
359<p>
360 Output a condensed summary of extended header information
361 such as creations, renames and mode changes.
362</p>
363</dd>
364<dt>
Junio C Hamanod1308c92006-04-16 11:01:09365--patch-with-stat
366</dt>
367<dd>
368<p>
Junio C Hamano9ae1a062006-07-10 08:12:34369 Synonym for "-p --stat".
Junio C Hamanod1308c92006-04-16 11:01:09370</p>
371</dd>
372<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23373-z
374</dt>
375<dd>
376<p>
377 \0 line termination on output
378</p>
379</dd>
380<dt>
381--name-only
382</dt>
383<dd>
384<p>
385 Show only names of changed files.
386</p>
387</dd>
388<dt>
389--name-status
390</dt>
391<dd>
392<p>
393 Show only names and status of changed files.
394</p>
395</dd>
396<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34397--color
398</dt>
399<dd>
400<p>
401 Show colored diff.
402</p>
403</dd>
404<dt>
405--no-color
406</dt>
407<dd>
408<p>
409 Turn off colored diff, even when the configuration file
410 gives the default to color output.
411</p>
412</dd>
413<dt>
Junio C Hamano85e45fa2006-08-13 07:47:41414--color-words
415</dt>
416<dd>
417<p>
418 Show colored word diff, i.e. color words which have changed.
419</p>
420</dd>
421<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34422--no-renames
423</dt>
424<dd>
425<p>
426 Turn off rename detection, even when the configuration
427 file gives the default to do so.
428</p>
429</dd>
430<dt>
Junio C Hamanoa890c4f2007-01-28 10:29:21431--check
432</dt>
433<dd>
434<p>
435 Warn if changes introduce trailing whitespace
436 or an indent that uses a space before a tab.
437</p>
438</dd>
439<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23440--full-index
441</dt>
442<dd>
443<p>
444 Instead of the first handful characters, show full
445 object name of pre- and post-image blob on the "index"
446 line when generating a patch format output.
447</p>
448</dd>
449<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34450--binary
451</dt>
452<dd>
453<p>
454 In addition to --full-index, output "binary diff" that
455 can be applied with "git apply".
456</p>
457</dd>
458<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23459--abbrev[=&lt;n&gt;]
460</dt>
461<dd>
462<p>
463 Instead of showing the full 40-byte hexadecimal object
464 name in diff-raw format output and diff-tree header
Junio C Hamano235a91e2006-01-07 01:13:58465 lines, show only handful hexdigits prefix. This is
Junio C Hamano1a4e8412005-12-27 08:17:23466 independent of --full-index option above, which controls
467 the diff-patch output format. Non default number of
468 digits can be specified with --abbrev=&lt;n&gt;.
469</p>
470</dd>
471<dt>
472-B
473</dt>
474<dd>
475<p>
476 Break complete rewrite changes into pairs of delete and create.
477</p>
478</dd>
479<dt>
480-M
481</dt>
482<dd>
483<p>
484 Detect renames.
485</p>
486</dd>
487<dt>
488-C
489</dt>
490<dd>
491<p>
492 Detect copies as well as renames.
493</p>
494</dd>
495<dt>
Junio C Hamano6ec31b92006-02-10 05:52:01496--diff-filter=[ACDMRTUXB*]
497</dt>
498<dd>
499<p>
500 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
501 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
502 type (mode) changed (<tt>T</tt>), are Unmerged (<tt>U</tt>), are
503 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
504 Any combination of the filter characters may be used.
505 When <tt>*</tt> (All-or-none) is added to the combination, all
506 paths are selected if there is any file that matches
507 other criteria in the comparison; if there is no file
508 that matches other criteria, nothing is selected.
509</p>
510</dd>
511<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23512--find-copies-harder
513</dt>
514<dd>
515<p>
516 For performance reasons, by default, -C option finds copies only
517 if the original file of the copy was modified in the same
518 changeset. This flag makes the command
519 inspect unmodified files as candidates for the source of
520 copy. This is a very expensive operation for large
521 projects, so use it with caution.
522</p>
523</dd>
524<dt>
525-l&lt;num&gt;
526</dt>
527<dd>
528<p>
529 -M and -C options require O(n^2) processing time where n
530 is the number of potential rename/copy targets. This
531 option prevents rename/copy detection from running if
532 the number of rename/copy targets exceeds the specified
533 number.
534</p>
535</dd>
536<dt>
537-S&lt;string&gt;
538</dt>
539<dd>
540<p>
541 Look for differences that contain the change in &lt;string&gt;.
542</p>
543</dd>
544<dt>
545--pickaxe-all
546</dt>
547<dd>
548<p>
549 When -S finds a change, show all the changes in that
550 changeset, not just the files that contain the change
551 in &lt;string&gt;.
552</p>
553</dd>
554<dt>
Junio C Hamanobfe9e752006-04-05 21:43:28555--pickaxe-regex
556</dt>
557<dd>
558<p>
559 Make the &lt;string&gt; not a plain string but an extended POSIX
560 regex to match.
561</p>
562</dd>
563<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23564-O&lt;orderfile&gt;
565</dt>
566<dd>
567<p>
568 Output the patch in the order specified in the
569 &lt;orderfile&gt;, which has one shell glob pattern per line.
570</p>
571</dd>
572<dt>
573-R
574</dt>
575<dd>
576<p>
577 Swap two inputs; that is, show differences from index or
578 on-disk file to tree contents.
579</p>
580</dd>
Junio C Hamanoc26f5482006-07-09 09:38:14581<dt>
582--text
583</dt>
584<dd>
585<p>
586 Treat all files as text.
587</p>
588</dd>
589<dt>
590-a
591</dt>
592<dd>
593<p>
594 Shorthand for "--text".
595</p>
596</dd>
Junio C Hamanod9c2d2f2006-12-06 08:59:07597<dt>
Junio C Hamanofd468962007-02-14 23:45:04598--ignore-space-at-eol
599</dt>
600<dd>
601<p>
602 Ignore changes in white spaces at EOL.
603</p>
604</dd>
605<dt>
Junio C Hamanod9c2d2f2006-12-06 08:59:07606--ignore-space-change
607</dt>
608<dd>
609<p>
610 Ignore changes in amount of white space. This ignores white
611 space at line end, and consider all other sequences of one or
612 more white space characters to be equivalent.
613</p>
614</dd>
615<dt>
616-b
617</dt>
618<dd>
619<p>
620 Shorthand for "--ignore-space-change".
621</p>
622</dd>
623<dt>
624--ignore-all-space
625</dt>
626<dd>
627<p>
628 Ignore white space when comparing lines. This ignores
629 difference even if one line has white space where the other
630 line has none.
631</p>
632</dd>
633<dt>
634-w
635</dt>
636<dd>
637<p>
638 Shorthand for "--ignore-all-space".
639</p>
640</dd>
Junio C Hamano48fd2f62007-03-19 02:02:30641<dt>
642--exit-code
643</dt>
644<dd>
645<p>
646 Make the program exit with codes similar to diff(1).
647 That is, it exits with 1 if there were differences and
648 0 means no differences.
649</p>
650</dd>
Junio C Hamano35e57552007-03-25 07:54:35651<dt>
652--quiet
653</dt>
654<dd>
655<p>
656 Disable all output of the program. Implies --exit-code.
657</p>
658</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23659</dl>
660<p>For more detailed explanation on these common options, see also
661<a href="diffcore.html">diffcore documentation</a>.</p>
662<dl>
663<dt>
664&lt;tree-ish&gt;
665</dt>
666<dd>
667<p>
668 The id of a tree object.
669</p>
670</dd>
671<dt>
672&lt;path&gt;&#8230;
673</dt>
674<dd>
675<p>
676 If provided, the results are limited to a subset of files
677 matching one of these prefix strings.
Junio C Hamano341071d2006-06-04 07:24:48678 i.e., file matches <tt>/^&lt;pattern1&gt;|&lt;pattern2&gt;|&#8230;/</tt>
Junio C Hamano1a4e8412005-12-27 08:17:23679 Note that this parameter does not provide any wildcard or regexp
680 features.
681</p>
682</dd>
683<dt>
684-r
685</dt>
686<dd>
687<p>
688 recurse into sub-trees
689</p>
690</dd>
691<dt>
692-t
693</dt>
694<dd>
695<p>
696 show tree entry itself as well as subtrees. Implies -r.
697</p>
698</dd>
699<dt>
700--root
701</dt>
702<dd>
703<p>
704 When <em>--root</em> is specified the initial commit will be showed as a big
705 creation event. This is equivalent to a diff against the NULL tree.
706</p>
707</dd>
708<dt>
709--stdin
710</dt>
711<dd>
712<p>
713 When <em>--stdin</em> is specified, the command does not take
714 &lt;tree-ish&gt; arguments from the command line. Instead, it
715 reads either one &lt;commit&gt; or a pair of &lt;tree-ish&gt;
716 separated with a single space from its standard input.
717</p>
718<p>When a single commit is given on one line of such input, it compares
719the commit with its parents. The following flags further affects its
Junio C Hamano341071d2006-06-04 07:24:48720behavior. This does not apply to the case where two &lt;tree-ish&gt;
Junio C Hamano1a4e8412005-12-27 08:17:23721separated with a single space are given.</p>
722</dd>
723<dt>
724-m
725</dt>
726<dd>
727<p>
728 By default, "git-diff-tree --stdin" does not show
729 differences for merge commits. With this flag, it shows
Junio C Hamanoa8adb1e2006-04-10 23:46:16730 differences to that commit from all of its parents. See
731 also <em>-c</em>.
Junio C Hamano1a4e8412005-12-27 08:17:23732</p>
733</dd>
734<dt>
735-s
736</dt>
737<dd>
738<p>
739 By default, "git-diff-tree --stdin" shows differences,
740 either in machine-readable form (without <em>-p</em>) or in patch
Junio C Hamano235a91e2006-01-07 01:13:58741 form (with <em>-p</em>). This output can be suppressed. It is
Junio C Hamano1a4e8412005-12-27 08:17:23742 only useful with <em>-v</em> flag.
743</p>
744</dd>
745<dt>
746-v
747</dt>
748<dd>
749<p>
750 This flag causes "git-diff-tree --stdin" to also show
751 the commit message before the differences.
752</p>
753</dd>
754<dt>
Junio C Hamanoa340aaa2006-11-23 02:47:33755--pretty[=<em>&lt;format&gt;</em>]
Junio C Hamano1a4e8412005-12-27 08:17:23756</dt>
757<dd>
758<p>
Junio C Hamano0430e3a2007-05-15 03:13:17759 Pretty print the contents of the commit logs in a given format,
760 where <em>&lt;format&gt;</em> can be one of <em>oneline</em>, <em>short</em>, <em>medium</em>,
761 <em>full</em>, <em>fuller</em>, <em>email</em>, <em>raw</em> and <em>format:&lt;string&gt;</em>.
762 When left out the format default to <em>medium</em>.
Junio C Hamano1a4e8412005-12-27 08:17:23763</p>
Junio C Hamano0430e3a2007-05-15 03:13:17764</dd>
765<dt>
766--encoding[=&lt;encoding&gt;]
767</dt>
768<dd>
769<p>
770 The commit objects record the encoding used for the log message
771 in their encoding header; this option can be used to tell the
772 command to re-code the commit log message in the encoding
773 preferred by the user. For non plumbing commands this
774 defaults to UTF-8.
775</p>
776</dd>
777<dt>
778--no-commit-id
779</dt>
780<dd>
781<p>
782 git-diff-tree outputs a line with the commit ID when
783 applicable. This flag suppressed the commit ID output.
784</p>
785</dd>
786<dt>
787-c
788</dt>
789<dd>
790<p>
791 This flag changes the way a merge commit is displayed
792 (which means it is useful only when the command is given
793 one &lt;tree-ish&gt;, or <em>--stdin</em>). It shows the differences
794 from each of the parents to the merge result simultaneously
795 instead of showing pairwise diff between a parent and the
796 result one at a time (which is what the <em>-m</em> option does).
797 Furthermore, it lists only files which were modified
798 from all parents.
799</p>
800</dd>
801<dt>
802--cc
803</dt>
804<dd>
805<p>
806 This flag changes the way a merge commit patch is displayed,
807 in a similar way to the <em>-c</em> option. It implies the <em>-c</em>
808 and <em>-p</em> options and further compresses the patch output
809 by omitting hunks that show differences from only one
810 parent, or show the same change from all but one parent
811 for an Octopus merge. When this optimization makes all
812 hunks disappear, the commit itself and the commit log
813 message is not shown, just like in any other "empty diff" case.
814</p>
815</dd>
816<dt>
817--always
818</dt>
819<dd>
820<p>
821 Show the commit itself and the commit log message even
822 if the diff itself is empty.
823</p>
824</dd>
825</dl>
826</div>
827<h2>PRETTY FORMATS</h2>
828<div class="sectionbody">
829<p>If the commit is a merge, and if the pretty-format
830is not <em>oneline</em>, <em>email</em> or <em>raw</em>, an additional line is
831inserted before the <em>Author:</em> line. This line begins with
832"Merge: " and the sha1s of ancestral commits are printed,
833separated by spaces. Note that the listed commits may not
834necessarily be the list of the <strong>direct</strong> parent commits if you
835have limited your view of history: for example, if you are
836only interested in changes related to a certain directory or
837file.</p>
838<p>Here are some additional details for each format:</p>
Junio C Hamanoa340aaa2006-11-23 02:47:33839<ul>
840<li>
841<p>
842<em>oneline</em>
843</p>
844<div class="literalblock">
845<div class="content">
846<pre><tt>&lt;sha1&gt; &lt;title line&gt;</tt></pre>
847</div></div>
848<p>This is designed to be as compact as possible.</p>
849</li>
850<li>
851<p>
852<em>short</em>
853</p>
854<div class="literalblock">
855<div class="content">
856<pre><tt>commit &lt;sha1&gt;
857Author: &lt;author&gt;</tt></pre>
858</div></div>
859<div class="literalblock">
860<div class="content">
861<pre><tt>&lt;title line&gt;</tt></pre>
862</div></div>
863</li>
864<li>
865<p>
866<em>medium</em>
867</p>
868<div class="literalblock">
869<div class="content">
870<pre><tt>commit &lt;sha1&gt;
871Author: &lt;author&gt;
872Date: &lt;date&gt;</tt></pre>
873</div></div>
874<div class="literalblock">
875<div class="content">
876<pre><tt>&lt;title line&gt;</tt></pre>
877</div></div>
878<div class="literalblock">
879<div class="content">
880<pre><tt>&lt;full commit message&gt;</tt></pre>
881</div></div>
882</li>
883<li>
884<p>
885<em>full</em>
886</p>
887<div class="literalblock">
888<div class="content">
889<pre><tt>commit &lt;sha1&gt;
890Author: &lt;author&gt;
891Commit: &lt;committer&gt;</tt></pre>
892</div></div>
893<div class="literalblock">
894<div class="content">
895<pre><tt>&lt;title line&gt;</tt></pre>
896</div></div>
897<div class="literalblock">
898<div class="content">
899<pre><tt>&lt;full commit message&gt;</tt></pre>
900</div></div>
901</li>
902<li>
903<p>
904<em>fuller</em>
905</p>
906<div class="literalblock">
907<div class="content">
908<pre><tt>commit &lt;sha1&gt;
909Author: &lt;author&gt;
910AuthorDate: &lt;date &amp; time&gt;
911Commit: &lt;committer&gt;
912CommitDate: &lt;date &amp; time&gt;</tt></pre>
913</div></div>
914<div class="literalblock">
915<div class="content">
916<pre><tt>&lt;title line&gt;</tt></pre>
917</div></div>
918<div class="literalblock">
919<div class="content">
920<pre><tt>&lt;full commit message&gt;</tt></pre>
921</div></div>
922</li>
923<li>
924<p>
925<em>email</em>
926</p>
927<div class="literalblock">
928<div class="content">
929<pre><tt>From &lt;sha1&gt; &lt;date&gt;
930From: &lt;author&gt;
931Date: &lt;date &amp; time&gt;
932Subject: [PATCH] &lt;title line&gt;</tt></pre>
933</div></div>
934<div class="literalblock">
935<div class="content">
Junio C Hamano0430e3a2007-05-15 03:13:17936<pre><tt>&lt;full commit message&gt;</tt></pre>
Junio C Hamanoa340aaa2006-11-23 02:47:33937</div></div>
938</li>
939<li>
940<p>
941<em>raw</em>
942</p>
943<p>The <em>raw</em> format shows the entire commit exactly as
944stored in the commit object. Notably, the SHA1s are
945displayed in full, regardless of whether --abbrev or
946--no-abbrev are used, and <em>parents</em> information show the
947true parent commits, without taking grafts nor history
948simplification into account.</p>
949</li>
Junio C Hamanoa3fd83c2007-03-02 10:34:36950<li>
951<p>
952<em>format:</em>
953</p>
954<p>The <em>format:</em> format allows you to specify which information
955you want to show. It works a little bit like printf format,
956with the notable exception that you get a newline with <em>%n</em>
957instead of <em>\n</em>.</p>
Junio C Hamano0430e3a2007-05-15 03:13:17958<p>E.g, <em>format:"The author of %h was %an, %ar%nThe title was &gt;&gt;%s&lt;&lt;%n"</em>
Junio C Hamanoa3fd83c2007-03-02 10:34:36959would show something like this:</p>
Junio C Hamano0430e3a2007-05-15 03:13:17960<div class="listingblock">
961<div class="content">
962<pre><tt>The author of fe6e0ee was Junio C Hamano, 23 hours ago
963The title was &gt;&gt;t4119: test autocomputing -p&lt;n&gt; for traditional diff input.&lt;&lt;
964</tt></pre>
965</div></div>
Junio C Hamanoa3fd83c2007-03-02 10:34:36966<p>The placeholders are:</p>
967<ul>
968<li>
969<p>
970<em>%H</em>: commit hash
971</p>
972</li>
973<li>
974<p>
975<em>%h</em>: abbreviated commit hash
976</p>
977</li>
978<li>
979<p>
980<em>%T</em>: tree hash
981</p>
982</li>
983<li>
984<p>
985<em>%t</em>: abbreviated tree hash
986</p>
987</li>
988<li>
989<p>
990<em>%P</em>: parent hashes
991</p>
992</li>
993<li>
994<p>
995<em>%p</em>: abbreviated parent hashes
996</p>
997</li>
998<li>
999<p>
1000<em>%an</em>: author name
1001</p>
1002</li>
1003<li>
1004<p>
1005<em>%ae</em>: author email
1006</p>
1007</li>
1008<li>
1009<p>
1010<em>%ad</em>: author date
1011</p>
1012</li>
1013<li>
1014<p>
1015<em>%aD</em>: author date, RFC2822 style
1016</p>
1017</li>
1018<li>
1019<p>
1020<em>%ar</em>: author date, relative
1021</p>
1022</li>
1023<li>
1024<p>
1025<em>%at</em>: author date, UNIX timestamp
1026</p>
1027</li>
1028<li>
1029<p>
1030<em>%cn</em>: committer name
1031</p>
1032</li>
1033<li>
1034<p>
1035<em>%ce</em>: committer email
1036</p>
1037</li>
1038<li>
1039<p>
1040<em>%cd</em>: committer date
1041</p>
1042</li>
1043<li>
1044<p>
1045<em>%cD</em>: committer date, RFC2822 style
1046</p>
1047</li>
1048<li>
1049<p>
1050<em>%cr</em>: committer date, relative
1051</p>
1052</li>
1053<li>
1054<p>
1055<em>%ct</em>: committer date, UNIX timestamp
1056</p>
1057</li>
1058<li>
1059<p>
1060<em>%e</em>: encoding
1061</p>
1062</li>
1063<li>
1064<p>
1065<em>%s</em>: subject
1066</p>
1067</li>
1068<li>
1069<p>
1070<em>%b</em>: body
1071</p>
1072</li>
1073<li>
1074<p>
1075<em>%Cred</em>: switch color to red
1076</p>
1077</li>
1078<li>
1079<p>
1080<em>%Cgreen</em>: switch color to green
1081</p>
1082</li>
1083<li>
1084<p>
1085<em>%Cblue</em>: switch color to blue
1086</p>
1087</li>
1088<li>
1089<p>
1090<em>%Creset</em>: reset color
1091</p>
1092</li>
1093<li>
1094<p>
Junio C Hamanod9e0e5d2007-04-14 16:22:041095<em>%m</em>: left, right or boundary mark
1096</p>
1097</li>
1098<li>
1099<p>
Junio C Hamanoa3fd83c2007-03-02 10:34:361100<em>%n</em>: newline
1101</p>
Junio C Hamano0430e3a2007-05-15 03:13:171102</li>
1103</ul>
Junio C Hamanoa3fd83c2007-03-02 10:34:361104</li>
1105</ul>
Junio C Hamano1a4e8412005-12-27 08:17:231106</div>
1107<h2>Limiting Output</h2>
1108<div class="sectionbody">
1109<p>If you're only interested in differences in a subset of files, for
1110example some architecture-specific files, you might do:</p>
1111<div class="literalblock">
1112<div class="content">
1113<pre><tt>git-diff-tree -r &lt;tree-ish&gt; &lt;tree-ish&gt; arch/ia64 include/asm-ia64</tt></pre>
1114</div></div>
1115<p>and it will only show you what changed in those two directories.</p>
1116<p>Or if you are searching for what changed in just <tt>kernel/sched.c</tt>, just do</p>
1117<div class="literalblock">
1118<div class="content">
1119<pre><tt>git-diff-tree -r &lt;tree-ish&gt; &lt;tree-ish&gt; kernel/sched.c</tt></pre>
1120</div></div>
1121<p>and it will ignore all differences to other files.</p>
1122<p>The pattern is always the prefix, and is matched exactly. There are no
1123wildcards. Even stricter, it has to match a complete path component.
1124I.e. "foo" does not pick up <tt>foobar.h</tt>. "foo" does match <tt>foo/bar.h</tt>
1125so it can be used to name subdirectories.</p>
1126<p>An example of normal usage is:</p>
1127<div class="literalblock">
1128<div class="content">
1129<pre><tt>torvalds@ppc970:~/git&gt; git-diff-tree 5319e4......
1130*100664-&gt;100664 blob ac348b.......-&gt;a01513....... git-fsck-objects.c</tt></pre>
1131</div></div>
1132<p>which tells you that the last commit changed just one file (it's from
1133this one:</p>
1134<div class="listingblock">
1135<div class="content">
1136<pre><tt>commit 3c6f7ca19ad4043e9e72fa94106f352897e651a8
1137tree 5319e4d609cdd282069cc4dce33c1db559539b03
1138parent b4e628ea30d5ab3606119d2ea5caeab141d38df7
1139author Linus Torvalds &lt;torvalds@ppc970.osdl.org&gt; Sat Apr 9 12:02:30 2005
1140committer Linus Torvalds &lt;torvalds@ppc970.osdl.org&gt; Sat Apr 9 12:02:30 2005
1141
1142Make "git-fsck-objects" print out all the root commits it finds.
1143
1144Once I do the reference tracking, I'll also make it print out all the
1145HEAD commits it finds, which is even more interesting.</tt></pre>
1146</div></div>
1147<p>in case you care).</p>
1148</div>
1149<h2>Output format</h2>
1150<div class="sectionbody">
1151<p>The output format from "git-diff-index", "git-diff-tree" and
1152"git-diff-files" are very similar.</p>
1153<p>These commands all compare two sets of things; what is
1154compared differs:</p>
1155<dl>
1156<dt>
1157git-diff-index &lt;tree-ish&gt;
1158</dt>
1159<dd>
1160<p>
1161 compares the &lt;tree-ish&gt; and the files on the filesystem.
1162</p>
1163</dd>
1164<dt>
1165git-diff-index --cached &lt;tree-ish&gt;
1166</dt>
1167<dd>
1168<p>
1169 compares the &lt;tree-ish&gt; and the index.
1170</p>
1171</dd>
1172<dt>
1173git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
1174</dt>
1175<dd>
1176<p>
1177 compares the trees named by the two arguments.
1178</p>
1179</dd>
1180<dt>
1181git-diff-files [&lt;pattern&gt;&#8230;]
1182</dt>
1183<dd>
1184<p>
1185 compares the index and the files on the filesystem.
1186</p>
1187</dd>
1188</dl>
1189<p>An output line is formatted this way:</p>
1190<div class="listingblock">
1191<div class="content">
1192<pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
1193copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
1194rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
1195create :000000 100644 0000000... 1234567... A file4
1196delete :100644 000000 1234567... 0000000... D file5
1197unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
1198</div></div>
1199<p>That is, from the left to the right:</p>
1200<ol>
1201<li>
1202<p>
1203a colon.
1204</p>
1205</li>
1206<li>
1207<p>
1208mode for "src"; 000000 if creation or unmerged.
1209</p>
1210</li>
1211<li>
1212<p>
1213a space.
1214</p>
1215</li>
1216<li>
1217<p>
1218mode for "dst"; 000000 if deletion or unmerged.
1219</p>
1220</li>
1221<li>
1222<p>
1223a space.
1224</p>
1225</li>
1226<li>
1227<p>
1228sha1 for "src"; 0{40} if creation or unmerged.
1229</p>
1230</li>
1231<li>
1232<p>
1233a space.
1234</p>
1235</li>
1236<li>
1237<p>
1238sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1239</p>
1240</li>
1241<li>
1242<p>
1243a space.
1244</p>
1245</li>
1246<li>
1247<p>
1248status, followed by optional "score" number.
1249</p>
1250</li>
1251<li>
1252<p>
1253a tab or a NUL when <em>-z</em> option is used.
1254</p>
1255</li>
1256<li>
1257<p>
1258path for "src"
1259</p>
1260</li>
1261<li>
1262<p>
1263a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1264</p>
1265</li>
1266<li>
1267<p>
1268path for "dst"; only exists for C or R.
1269</p>
1270</li>
1271<li>
1272<p>
1273an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1274</p>
1275</li>
1276</ol>
1277<p>&lt;sha1&gt; is shown as all 0's if a file is new on the filesystem
1278and it is out of sync with the index.</p>
1279<p>Example:</p>
1280<div class="listingblock">
1281<div class="content">
1282<pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1283</div></div>
1284<p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
1285in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
1286respectively.</p>
1287</div>
Junio C Hamano67fad6d2007-05-06 08:53:121288<h2>diff format for merges</h2>
1289<div class="sectionbody">
1290<p>"git-diff-tree" and "git-diff-files" can take <em>-c</em> or <em>--cc</em> option
1291to generate diff output also for merge commits. The output differs
1292from the format described above in the following way:</p>
1293<ol>
1294<li>
1295<p>
1296there is a colon for each parent
1297</p>
1298</li>
1299<li>
1300<p>
1301there are more "src" modes and "src" sha1
1302</p>
1303</li>
1304<li>
1305<p>
1306status is concatenated status characters for each parent
1307</p>
1308</li>
1309<li>
1310<p>
1311no optional "score" number
1312</p>
1313</li>
1314<li>
1315<p>
1316single path, only for "dst"
1317</p>
1318</li>
1319</ol>
1320<p>Example:</p>
1321<div class="listingblock">
1322<div class="content">
1323<pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
1324</div></div>
1325<p>Note that <em>combined diff</em> lists only files which were modified from
1326all parents.</p>
1327</div>
Junio C Hamano1a4e8412005-12-27 08:17:231328<h2>Generating patches with -p</h2>
1329<div class="sectionbody">
1330<p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
1331with a <em>-p</em> option, they do not produce the output described above;
Junio C Hamano1c437122006-11-28 02:22:251332instead they produce a patch file. You can customize the creation
1333of such patches via the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS
1334environment variables.</p>
1335<p>What the -p option produces is slightly different from the traditional
1336diff format.</p>
Junio C Hamano1a4e8412005-12-27 08:17:231337<ol>
1338<li>
1339<p>
Junio C Hamano235a91e2006-01-07 01:13:581340It is preceded with a "git diff" header, that looks like
Junio C Hamano1a4e8412005-12-27 08:17:231341 this:
1342</p>
1343<div class="literalblock">
1344<div class="content">
1345<pre><tt>diff --git a/file1 b/file2</tt></pre>
1346</div></div>
1347<p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
1348involved. Especially, even for a creation or a deletion,
1349<tt>/dev/null</tt> is _not_ used in place of <tt>a/</tt> or <tt>b/</tt> filenames.</p>
1350<p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
1351name of the source file of the rename/copy and the name of
1352the file that rename/copy produces, respectively.</p>
1353</li>
1354<li>
1355<p>
1356It is followed by one or more extended header lines:
1357</p>
1358<div class="literalblock">
1359<div class="content">
1360<pre><tt>old mode &lt;mode&gt;
1361new mode &lt;mode&gt;
1362deleted file mode &lt;mode&gt;
1363new file mode &lt;mode&gt;
1364copy from &lt;path&gt;
1365copy to &lt;path&gt;
1366rename from &lt;path&gt;
1367rename to &lt;path&gt;
1368similarity index &lt;number&gt;
1369dissimilarity index &lt;number&gt;
1370index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
1371</div></div>
1372</li>
1373<li>
1374<p>
Junio C Hamanoa053d542006-10-27 09:29:131375TAB, LF, double quote and backslash characters in pathnames
1376 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
1377 If there is need for such substitution then the whole
1378 pathname is put in double quotes.
Junio C Hamano1a4e8412005-12-27 08:17:231379</p>
1380</li>
1381</ol>
1382</div>
Junio C Hamanofb56a962006-01-28 10:38:191383<h2>combined diff format</h2>
1384<div class="sectionbody">
1385<p>git-diff-tree and git-diff-files can take <em>-c</em> or <em>--cc</em> option
1386to produce <em>combined diff</em>, which looks like this:</p>
1387<div class="listingblock">
1388<div class="content">
1389<pre><tt>diff --combined describe.c
Junio C Hamano29f14312006-10-26 08:47:291390index fabadb8,cc95eb0..4866510
1391--- a/describe.c
1392+++ b/describe.c
1393@@@ -98,20 -98,12 +98,20 @@@
1394 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
Junio C Hamanofb56a962006-01-28 10:38:191395 }
1396
1397- static void describe(char *arg)
1398 -static void describe(struct commit *cmit, int last_one)
1399++static void describe(char *arg, int last_one)
1400 {
Junio C Hamano29f14312006-10-26 08:47:291401 + unsigned char sha1[20];
1402 + struct commit *cmit;
1403 struct commit_list *list;
1404 static int initialized = 0;
1405 struct commit_name *n;
1406
1407 + if (get_sha1(arg, sha1) &lt; 0)
1408 + usage(describe_usage);
1409 + cmit = lookup_commit_reference(sha1);
1410 + if (!cmit)
1411 + usage(describe_usage);
1412 +
1413 if (!initialized) {
1414 initialized = 1;
1415 for_each_ref(get_name);</tt></pre>
Junio C Hamanofb56a962006-01-28 10:38:191416</div></div>
Junio C Hamano29f14312006-10-26 08:47:291417<ol>
1418<li>
1419<p>
1420It is preceded with a "git diff" header, that looks like
1421 this (when <em>-c</em> option is used):
1422</p>
1423<div class="literalblock">
1424<div class="content">
1425<pre><tt>diff --combined file</tt></pre>
1426</div></div>
1427<p>or like this (when <em>--cc</em> option is used):</p>
1428<div class="literalblock">
1429<div class="content">
1430<pre><tt>diff --c file</tt></pre>
1431</div></div>
1432</li>
1433<li>
1434<p>
1435It is followed by one or more extended header lines
1436 (this example shows a merge with two parents):
1437</p>
1438<div class="literalblock">
1439<div class="content">
1440<pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1441mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1442new file mode &lt;mode&gt;
1443deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1444</div></div>
1445<p>The <tt>mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;</tt> line appears only if at least one of
Junio C Hamanoee1e4282007-02-04 08:32:041446the &lt;mode&gt; is different from the rest. Extended headers with
Junio C Hamano29f14312006-10-26 08:47:291447information about detected contents movement (renames and
1448copying detection) are designed to work with diff of two
1449&lt;tree-ish&gt; and are not used by combined diff format.</p>
1450</li>
1451<li>
1452<p>
1453It is followed by two-line from-file/to-file header
1454</p>
1455<div class="literalblock">
1456<div class="content">
1457<pre><tt>--- a/file
1458+++ b/file</tt></pre>
1459</div></div>
1460<p>Similar to two-line header for traditional <em>unified</em> diff
1461format, <tt>/dev/null</tt> is used to signal created or deleted
1462files.</p>
1463</li>
1464<li>
1465<p>
1466Chunk header format is modified to prevent people from
1467 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1468 was created for review of merge commit changes, and was not
1469 meant for apply. The change is similar to the change in the
1470 extended <em>index</em> header:
1471</p>
1472<div class="literalblock">
1473<div class="content">
1474<pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1475</div></div>
1476<p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1477header for combined diff format.</p>
1478</li>
1479</ol>
Junio C Hamanofb56a962006-01-28 10:38:191480<p>Unlike the traditional <em>unified</em> diff format, which shows two
1481files A and B with a single column that has <tt>-</tt> (minus &#8212;
1482appears in A but removed in B), <tt>+</tt> (plus &#8212; missing in A but
Junio C Hamano29f14312006-10-26 08:47:291483added to B), or <tt>" "</tt> (space &#8212; unchanged) prefix, this format
Junio C Hamanofb56a962006-01-28 10:38:191484compares two or more files file1, file2,&#8230; with one file X, and
1485shows how X differs from each of fileN. One column for each of
1486fileN is prepended to the output line to note how X's line is
1487different from it.</p>
1488<p>A <tt>-</tt> character in the column N means that the line appears in
Junio C Hamano29f14312006-10-26 08:47:291489fileN but it does not appear in the result. A <tt>+</tt> character
Junio C Hamanofb56a962006-01-28 10:38:191490in the column N means that the line appears in the last file,
Junio C Hamano29f14312006-10-26 08:47:291491and fileN does not have that line (in other words, the line was
1492added, from the point of view of that parent).</p>
Junio C Hamanofb56a962006-01-28 10:38:191493<p>In the above example output, the function signature was changed
1494from both files (hence two <tt>-</tt> removals from both file1 and
1495file2, plus <tt>++</tt> to mean one line that was added does not appear
1496in either file1 nor file2). Also two other lines are the same
1497from file1 but do not appear in file2 (hence prefixed with <tt> +</tt>).</p>
1498<p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
1499merge commit with the merge result (i.e. file1..fileN are the
1500parents). When shown by <tt>git diff-files -c</tt>, it compares the
1501two unresolved merge parents with the working tree file
1502(i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
1503"their version").</p>
1504</div>
Junio C Hamano1a4e8412005-12-27 08:17:231505<h2>Author</h2>
1506<div class="sectionbody">
1507<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p>
1508</div>
1509<h2>Documentation</h2>
1510<div class="sectionbody">
1511<p>Documentation by David Greaves, Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p>
1512</div>
1513<h2>GIT</h2>
1514<div class="sectionbody">
1515<p>Part of the <a href="git.html">git(7)</a> suite</p>
1516</div>
1517<div id="footer">
1518<div id="footer-text">
Junio C Hamanoa77a5132007-06-08 16:13:441519Last updated 08-Jun-2007 16:08:08 UTC
Junio C Hamano1a4e8412005-12-27 08:17:231520</div>
1521</div>
1522</body>
1523</html>